﻿<UserControl x:Class="ModernAudioTagger.Content.ContentDbResult"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:provider="clr-namespace:ModernAudioTagger.Provider"
             xmlns:blogic="clr-namespace:ModernAudioTagger.BusinessLogic"
             xmlns:helper="clr-namespace:ModernAudioTagger.Helpers"             
             xmlns:converter="clr-namespace:ModernAudioTagger.Converter"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"                
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"                   
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">


    <UserControl.DataContext>
        <Binding Source="{x:Static provider:ViewModelLocator.Instance}" Path="MusicDbVM" />
    </UserControl.DataContext>
    
    <UserControl.Resources>
        <converter:TrackLengthConverter x:Key="lengthConverter" />
    </UserControl.Resources>

    <Grid>
        <ListView
                BorderThickness="1"
                BorderBrush="{DynamicResource SeparatorBackground}"
                FontSize="{StaticResource SmallFontSize}" 
                ItemsSource="{Binding ListDbResult}"                                        
                SelectionMode="Single"
                helper:ListBoxMultipleSelectorHelper.SelectedItems="{Binding SelectedDbResult, Mode=TwoWay}"            
                >
            <!---->
            <ListView.View>
                <GridView>                    
                    <GridViewColumn Width="30" DisplayMemberBinding="{Binding Track, StringFormat='00'}" >
                        <GridViewColumn.Header>
                            <GridViewColumnHeader Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=MusicDbVM.OrderTracksByPositionCommand}">
                                <GridViewColumnHeader.Content>#</GridViewColumnHeader.Content>
                            </GridViewColumnHeader>
                        </GridViewColumn.Header>
                    </GridViewColumn>
                    <GridViewColumn Width="200" Header="Title" DisplayMemberBinding="{Binding Title}" />
                    <GridViewColumn Header="Length" DisplayMemberBinding="{Binding Length, Converter={StaticResource lengthConverter}}" />
                </GridView>
            </ListView.View>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <i:InvokeCommandAction Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=TrackTagVM.ShowTrackTagCommand}" CommandParameter="{Binding SelectedDbResult}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </ListView>

        <!--
        <DockPanel>
            <DataGrid Margin="{StaticResource DefaultMargin}" FontSize="{StaticResource SmallFontSize}" ItemsSource="{Binding Source={StaticResource spyMusicDbVM}, Path=DataContext.ListDbResult}" IsReadOnly="True" AutoGenerateColumns="False" SelectedItem="{Binding Source={StaticResource spyTrackTagVM}, Path=DataContext.SelectedTagTrack, Mode=TwoWay}">
                <DataGrid.Columns>
                    <mui:DataGridTextColumn Header="#" Binding="{Binding Track}" />
                    <mui:DataGridTextColumn Header="Title" Binding="{Binding Title}" />
                </DataGrid.Columns>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <i:InvokeCommandAction Command="{Binding Source={StaticResource spyTrackTagVM}, Path=DataContext.UpdateTagTrackCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </DataGrid>
        </DockPanel>
        -->
    </Grid>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{Binding ProxyChangedCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>

</UserControl>
